﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="admin.aspx.cs" Inherits="WebApplication1.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        .style3
        {
            font-size: medium;
            color: #000000;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConflictDetection="CompareAllValues" 
        ConnectionString="<%$ ConnectionStrings:theknowledgebaseConnectionString %>" 
        DeleteCommand="DELETE FROM [terms] WHERE [id_term] = @original_id_term AND (([d_id] = @original_d_id) OR ([d_id] IS NULL AND @original_d_id IS NULL)) AND [definition] = @original_definition AND [termname] = @original_termname" 
        InsertCommand="INSERT INTO [terms] ([d_id], [definition], [termname]) VALUES (@d_id, @definition, @termname)" 
        OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT [d_id], [definition], [termname], [id_term] FROM [terms] WHERE ([d_id] = @d_id)" 
        
        
    UpdateCommand="UPDATE [terms] SET [d_id] = @d_id, [definition] = @definition, [termname] = @termname WHERE [id_term] = @original_id_term AND (([d_id] = @original_d_id) OR ([d_id] IS NULL AND @original_d_id IS NULL)) AND [definition] = @original_definition AND [termname] = @original_termname">
        <DeleteParameters>
            <asp:Parameter Name="original_id_term" Type="Int32" />
            <asp:Parameter Name="original_d_id" Type="Int32" />
            <asp:Parameter Name="original_definition" Type="String" />
            <asp:Parameter Name="original_termname" Type="String" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="d_id" Type="Int32" />
            <asp:Parameter Name="definition" Type="String" />
            <asp:Parameter Name="termname" Type="String" />
        </InsertParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="DropDownList2" Name="d_id" 
                PropertyName="SelectedValue" Type="Int32" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="d_id" Type="Int32" />
            <asp:Parameter Name="definition" Type="String" />
            <asp:Parameter Name="termname" Type="String" />
            <asp:Parameter Name="original_id_term" Type="Int32" />
            <asp:Parameter Name="original_d_id" Type="Int32" />
            <asp:Parameter Name="original_definition" Type="String" />
            <asp:Parameter Name="original_termname" Type="String" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:theknowledgebaseConnectionString %>" 
        OldValuesParameterFormatString="original_{0}" 
        
        
        SelectCommand="SELECT [id_term], [termname], [definition], [d_id] FROM [terms] WHERE ([id_term] = @id_term)" 
        ConflictDetection="CompareAllValues" 
        DeleteCommand="DELETE FROM [terms] WHERE [id_term] = @original_id_term AND [termname] = @original_termname AND [definition] = @original_definition AND [d_id] = @original_d_id" 
        InsertCommand="INSERT INTO [terms] ([termname], [definition], [d_id]) VALUES (@termname, @definition, @d_id)" 
        UpdateCommand="UPDATE [terms] SET [termname] = @termname, [definition] = @definition, [d_id] = @d_id WHERE [id_term] = @original_id_term AND [termname] = @original_termname AND [definition] = @original_definition AND [d_id] = @original_d_id">
        <DeleteParameters>
            <asp:Parameter Name="original_id_term" Type="Int32" />
            <asp:Parameter Name="original_termname" Type="String" />
            <asp:Parameter Name="original_definition" Type="String" />
            <asp:Parameter Name="original_d_id" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="termname" Type="String" />
            <asp:Parameter Name="definition" Type="String" />
            <asp:Parameter Name="d_id" Type="Int32" />
        </InsertParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="GridView1" Name="id_term" 
                PropertyName="SelectedValue" Type="Int32" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="termname" Type="String" />
            <asp:Parameter Name="definition" Type="String" />
            <asp:Parameter Name="d_id" Type="Int32" />
            <asp:Parameter Name="original_id_term" Type="Int32" />
            <asp:Parameter Name="original_termname" Type="String" />
            <asp:Parameter Name="original_definition" Type="String" />
            <asp:Parameter Name="original_d_id" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
        ConnectionString="<%$ ConnectionStrings:theknowledgebaseConnectionString %>" 
        SelectCommand="SELECT [id_domain], [domain] FROM [domain]">
    </asp:SqlDataSource>
    <div>
        <span class="style3">Выберете тематику:</span>
        <asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True" 
            DataSourceID="SqlDataSource3" DataTextField="domain" DataValueField="id_domain">
        </asp:DropDownList>
    </div>
    <br />
    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
        CellPadding="4" DataKeyNames="id_term" DataSourceID="SqlDataSource2" 
        ForeColor="#333333" GridLines="None" Height="50px" Width="907px" 
    onitemdeleted="DetailsView1_ItemDeleted" 
    oniteminserted="DetailsView1_ItemInserted" 
        onitemupdated="DetailsView1_ItemUpdated">
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
        <EditRowStyle BackColor="#999999" />
        <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
        <Fields>
            <asp:TemplateField HeaderText="Термин" SortExpression="termname">
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("termname") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Height="21px" 
                        Text='<%# Bind("termname") %>' Width="650px"></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("termname") %>' 
                        Width="650px"></asp:TextBox>
                </InsertItemTemplate>
                <ItemStyle Width="700px" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Определение" SortExpression="definition">
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("definition") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("definition") %>' 
                        Width="650px"></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("definition") %>' 
                        Width="650px"></asp:TextBox>
                </InsertItemTemplate>
                <ItemStyle Width="700px" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="ID тематики" SortExpression="d_id">
                <ItemTemplate>
                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("d_id") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("d_id") %>' 
                        Width="650px"></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("d_id") %>' 
                        Width="650px"></asp:TextBox>
                </InsertItemTemplate>
                <ItemStyle Width="700px" />
            </asp:TemplateField>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" 
                ShowInsertButton="True" ButtonType="Image" 
                CancelImageUrl="~/images/cancel.png" DeleteImageUrl="~/images/delete.png" 
                EditImageUrl="~/images/Изменить.png" InsertImageUrl="~/images/save.png" 
                NewImageUrl="~/images/new.png" UpdateImageUrl="~/images/update.png" />
        </Fields>
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
    </asp:DetailsView>
    <br />
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" 
        DataKeyNames="id_term" DataSourceID="SqlDataSource1" ForeColor="#333333" 
        GridLines="None" Width="911px" PageSize="20">
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        <Columns>
            <asp:CommandField ButtonType="Image" CancelImageUrl="~/images/cancel.png" 
                DeleteImageUrl="~/images/delete.png" EditImageUrl="~/images/Изменить.png" 
                InsertImageUrl="~/images/save.png" NewImageUrl="~/images/new.png" 
                SelectImageUrl="~/images/select.png" ShowSelectButton="True" 
                UpdateImageUrl="~/images/update.png"></asp:CommandField>
            <asp:TemplateField HeaderText="Термин" SortExpression="termname">
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("termname") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Height="15px" 
                        Text='<%# Bind("termname") %>' Width="200px"></asp:TextBox>
                </EditItemTemplate>
                <ControlStyle Height="15px" />
                <ItemStyle Height="15px" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Определение" SortExpression="definition">
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("definition") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("definition") %>' 
                        Height="16px" Width="600px"></asp:TextBox>
                </EditItemTemplate>
                <ControlStyle Height="15px" />
                <ItemStyle Height="15px" />
            </asp:TemplateField>
        </Columns>
        <EditRowStyle BackColor="#999999" />
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
        <SortedAscendingCellStyle BackColor="#E9E7E2" />
        <SortedAscendingHeaderStyle BackColor="#506C8C" />
        <SortedDescendingCellStyle BackColor="#FFFDF8" />
        <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
    </asp:GridView>
</asp:Content>
